﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page
{
    static int i = 0;

    TextBox t =  new TextBox();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (i != 0)
            Panel1.Controls.Add(new TextBox());
        else
        {
            var x = new Label();
            x.Text = "ded";
            Panel1.Controls.Add(x);

        }    
    }

    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
    
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
          
        if (i % 2 == 0)
            Panel1.Controls.Add(new TextBox());
        else
        {
            var x = new Label();
            x.Text = "ded";
            Panel1.Controls.Add(x);

        } 
    }
}